home *** CD-ROM | disk | FTP | other *** search
- void mprintf(char *s);
-
- #include <stdio.h>
- #include <stdlib.h>
- #include <alloc.h>
- #include <conio.h>
- #include <dos.h>
- #include <string.h>
-
- #include "loadpcx.h"
-
- #define NUMY_lb 10
- #define NUMY_hb 11
- #define NUMX_lb 66 /* In bytes, not pixels */
- #define NUMX_hb 67
-
- #define REP_MASK 0xC0
- #define CNT_MASK 0x3f
-
- #define MAKE_WORD(h,l) ((header[h] << 8) + header[l])
-
- static int pcolor=3;
-
- /*<f>----------------------------------------
- * FUNCTION: <s> void Load_CGA_PCX(char *fn)
- * PURPOSE : Load in a CGA (ONLY!) .PCX file into screen buffer
- * :
- * CREATION: 02/13/1989 13:32:39
- */
- void Load_CGA_PCX(char *fn)
- {
- FILE *fp;
- unsigned char header[130];
- int nx,ny, size;
- int count, rep, data;
- unsigned char far *buf;
- unsigned char far *pbuf;
- unsigned char far *pbuf1;
- unsigned char far *scr;
- unsigned char far *scr1;
- int swap,b;
- int odd;
-
- randomize();
-
- buf=(unsigned char far *) farmalloc(25000L);
- if (buf==0L) {
- printf("Cannot alloc() memory for screen buffer\n");
- exit(1);
- }
-
- if ((fp=fopen(fn,"rb"))==NULL) {
- printf("Cannot fopen \"%s\" for input\n",fn);
- farfree(buf);
- exit(1);
- }
-
- pbuf=buf;
-
- fread(header,128,1,fp);
-
- nx=MAKE_WORD(NUMY_hb, NUMY_lb);
- ny=MAKE_WORD(NUMX_hb, NUMX_lb);
-
- size=(ny+1)*nx;
-
- count=0; swap=0; odd=0;
-
- while (count<size) {
-
- rep=1;
- b=getc(fp) & 255;
-
- if (REP_MASK == (REP_MASK & b)) {
- rep = CNT_MASK & b;
- b = getc(fp) & 255;
- }
- data = b;
-
- count += rep;
- swap += rep;
- while (rep--)
- *pbuf++ = data;
- if (swap>=80) {
- if (!odd)
- pbuf+=(0x2000-80);
- else
- pbuf-=0x2000;
- odd=~odd;
- swap-=80;
- }
- }
-
- scr =(unsigned char far *) 0xB8000000L;
- scr1=(unsigned char far *) 0xB8002000L;
-
- /* ---- WIPE #1 Top to Bottom & bottom to top */
- /*
- pbuf=buf;
- pbuf1=buf+0x2000+8000;
- scr1+=8000;
-
- for (b=0; b<8000; b++) {
- *scr++ =*pbuf++;
- *scr1--=*pbuf1--;
- delay(1);
- }
- */
- /* ----- */
-
- for (b=0; b<8000; b++) {
-
- count=random(8000);
- pbuf=buf+count;
- pbuf1=buf+0x2000+count;
-
- scr =(unsigned char far *) 0xB8000000L+count;
- scr1=(unsigned char far *) 0xB8002000L+count;
-
- *scr =*pbuf;
- *scr1=*pbuf1;
- }
-
- pbuf=buf;
- pbuf1=buf+0x2000;
- scr =(unsigned char far *) 0xB8000000L;
- scr1=(unsigned char far *) 0xB8002000L;
-
- for (b=0; b<8000; b++) {
- *scr++ =*pbuf++;
- *scr1++=*pbuf1++;
- }
- /* ----- */
-
- fclose(fp);
- farfree(buf);
- } /* void Load_CGA_PCX(char *fn) */
-
- /*<f>----------------------------------------
- * FUNCTION: <s> void set_screen_mode(int mode)
- * PURPOSE : Set screen mode thru BIOS int 10h
- * :
- * CREATION: 02/13/1989 13:34:46
- */
- void set_screen_mode(int mode)
- {
- union REGS iregs, oregs;
-
- iregs.h.ah=0;
- iregs.h.al=mode;
- int86(0x10,&iregs,&oregs);
-
- } /* void set_screen_mode(int mode) */
-
- /*<f>----------------------------------------
- * FUNCTION: <s> void mprintf(char *s)
- * PURPOSE :
- * :
- * CREATION: 02/14/1989 16:31:42
- */
- void mprintf(char *s)
- {
- int a;
- union REGS ireg, oreg;
-
- for (a=0; a<strlen(s); a++) {
- ireg.h.ah=0x0A;
- ireg.h.al=(char) *(s+a);
- ireg.h.bh=0;
- ireg.h.bl=128+pcolor;
- ireg.x.cx=1;
- int86(0x10,&ireg,&oreg);
- gotoxy(wherex()+1,wherey());
- }
-
- } /* void mprintf(char *s) */